sgdk
|
VDP General Tile / Tilemap operations. More...
Go to the source code of this file.
Classes | |
struct | TileSet |
struct | Map |
Defines | |
#define | TILE_ATTR_PRIORITY_MASK 0x8000 |
#define | TILE_ATTR_PALETTE_MASK 0x6000 |
#define | TILE_ATTR_VFLIP_MASK 0x1000 |
#define | TILE_ATTR_HFLIP_MASK 0x0800 |
#define | TILE_ATTR_MASK (TILE_ATTR_PRIORITY_MASK | TILE_ATTR_PALETTE_MASK | TILE_ATTR_VFLIP_MASK | TILE_ATTR_HFLIP_MASK) |
#define | TILE_ATTR(pal, prio, flipV, flipH) (((flipH) << 11) + ((flipV) << 12) + ((pal) << 13) + ((prio) << 15)) |
#define | TILE_ATTR_FULL(pal, prio, flipV, flipH, index) (((flipH) << 11) + ((flipV) << 12) + ((pal) << 13) + ((prio) << 15) + (index)) |
Functions | |
void | VDP_loadTileData (const u32 *data, u16 index, u16 num, u8 use_dma) |
Load tile data (pattern) in VRAM. | |
u16 | VDP_loadTileSet (const TileSet *tileset, u16 index, u8 use_dma) |
Load tile data (pattern) in VRAM. | |
void | VDP_loadFontData (const u32 *font, u16 length, u8 use_dma) |
Load font tile data in VRAM. Note that you should prefer the VDP_loadBMPFont(..) method to this one (easier to use). | |
u16 | VDP_loadFont (const TileSet *font, u8 use_dma) |
Load font from the specified TileSet structure. | |
void | VDP_loadBMPTileData (const u32 *data, u16 index, u16 w, u16 h, u16 bmp_w) |
Load 4bpp bitmap tile data in VRAM. | |
void | VDP_loadBMPTileDataEx (const u32 *data, u16 index, u16 x, u16 y, u16 w, u16 h, u16 bmp_w) |
Load 4bpp bitmap tile data in VRAM. | |
void | VDP_fillTileData (u8 value, u16 index, u16 num, u8 use_dma) |
Fill tile data in VRAM. | |
void | VDP_setTileMap (u16 plan, u16 tile, u16 ind) |
Set tilemap data at single position. | |
void | VDP_setTileMapXY (u16 plan, u16 tile, u16 x, u16 y) |
Set tilemap data at single position. | |
void | VDP_fillTileMapRectByIndex (u16 plan, u16 tile, u16 ind, u16 num) |
void | VDP_fillTileMap (u16 plan, u16 tile, u16 ind, u16 num) |
Fill tilemap data. | |
void | VDP_fillTileMapRect (u16 plan, u16 tile, u16 x, u16 y, u16 w, u16 h) |
Fill tilemap data at specified region. | |
void | VDP_clearTileMapRectByIndex (u16 plan, u16 ind, u16 num, u8 use_dma) |
void | VDP_clearTileMap (u16 plan, u16 ind, u16 num, u8 use_dma) |
Clear tilemap data. | |
void | VDP_clearTileMapRect (u16 plan, u16 x, u16 y, u16 w, u16 h) |
Clear tilemap data at specified region. | |
void | VDP_fillTileMapRectIncByIndex (u16 plan, u16 basetile, u16 ind, u16 num) |
void | VDP_fillTileMapInc (u16 plan, u16 basetile, u16 ind, u16 num) |
Fill tilemap data with index auto increment. | |
void | VDP_fillTileMapRectInc (u16 plan, u16 basetile, u16 x, u16 y, u16 w, u16 h) |
Fill tilemap data with index auto increment at specified region. | |
void | VDP_setTileMapRectByIndex (u16 plan, const u16 *data, u16 ind, u16 num, u8 use_dma) |
void | VDP_setTileMapData (u16 plan, const u16 *data, u16 ind, u16 num, u8 use_dma) |
Load tilemap data at specified index. | |
void | VDP_setTileMapDataRect (u16 plan, const u16 *data, u16 x, u16 y, u16 w, u16 h) |
Load tilemap data at specified region. | |
void | VDP_setTileMapRectExByIndex (u16 plan, const u16 *data, u16 baseindex, u16 baseflags, u16 ind, u16 num) |
Use VDP_setTileMapDataEx() instead. | |
void | VDP_setTileMapDataEx (u16 plan, const u16 *data, u16 basetile, u16 ind, u16 num) |
Load tilemap data at specified index (extended version). | |
void | VDP_setTileMapRectEx (u16 plan, const u16 *data, u16 baseindex, u16 baseflags, u16 x, u16 y, u16 w, u16 h) |
void | VDP_setTileMapDataRectEx (u16 plan, const u16 *data, u16 basetile, u16 x, u16 y, u16 w, u16 h, u16 wm) |
Load tilemap data at specified region (extended version). | |
u16 | VDP_setMap (u16 plan, const Map *map, u16 basetile, u16 x, u16 y) |
Load Map at specified position. | |
u16 | VDP_setMapEx (u16 plan, const Map *map, u16 basetile, u16 x, u16 y, u16 xm, u16 ym, u16 wm, u16 hm) |
Load Map region at specified position. |
VDP General Tile / Tilemap operations.
This unit provides methods to manipulate VDP tiles and tilemap :
#define TILE_ATTR | ( | pal, | |
prio, | |||
flipV, | |||
flipH | |||
) | (((flipH) << 11) + ((flipV) << 12) + ((pal) << 13) + ((prio) << 15)) |
Encode tile attributes for tilemap data.
pal | Palette index |
prio | Tile priority |
flipV | Vertical flip |
flipH | Horizontal flip |
#define TILE_ATTR_FULL | ( | pal, | |
prio, | |||
flipV, | |||
flipH, | |||
index | |||
) | (((flipH) << 11) + ((flipV) << 12) + ((pal) << 13) + ((prio) << 15) + (index)) |
Encode tile attributes for tilemap data.
pal | Palette index |
prio | Tile priority |
flipV | Vertical flip |
flipH | Horizontal flip |
index | Tile index |
#define TILE_ATTR_HFLIP_MASK 0x0800 |
Mask for the tile H flip attribute in tilemap data.
#define TILE_ATTR_MASK (TILE_ATTR_PRIORITY_MASK | TILE_ATTR_PALETTE_MASK | TILE_ATTR_VFLIP_MASK | TILE_ATTR_HFLIP_MASK) |
Mask for the tile attributes (priority, palette and flip) in tilemap data.
#define TILE_ATTR_PALETTE_MASK 0x6000 |
Mask for the tile palette attribute in tilemap data.
#define TILE_ATTR_PRIORITY_MASK 0x8000 |
Mask for the tile priority attribute in tilemap data.
#define TILE_ATTR_VFLIP_MASK 0x1000 |
Mask for the tile V flip attribute in tilemap data.
void VDP_clearTileMap | ( | u16 | plan, |
u16 | ind, | ||
u16 | num, | ||
u8 | use_dma | ||
) |
Clear tilemap data.
plan | Plan where we want to clear tilemap region. Accepted values are:
|
ind | Tile index where to start fill. |
num | Number of tile to fill. |
use_dma | Use DMA transfert (faster but can lock Z80 execution). |
void VDP_clearTileMapRect | ( | u16 | plan, |
u16 | x, | ||
u16 | y, | ||
u16 | w, | ||
u16 | h | ||
) |
Clear tilemap data at specified region.
plan | Plan where we want to clear tilemap region. Accepted values are:
|
x | Region X start position (in tile). |
y | Region Y start position (in tile). |
w | Region Width (in tile). |
h | Region Heigh (in tile). |
void VDP_clearTileMapRectByIndex | ( | u16 | plan, |
u16 | ind, | ||
u16 | num, | ||
u8 | use_dma | ||
) |
void VDP_fillTileData | ( | u8 | value, |
u16 | index, | ||
u16 | num, | ||
u8 | use_dma | ||
) |
Fill tile data in VRAM.
value | Value (byte) used to fill VRAM tile data. |
index | Tile index where start tile data fill (use TILE_USERINDEX as base user index). |
num | Number of tile to fill. |
use_dma | Use DMA transfert (faster but can lock Z80 execution). |
This function is generally used to clear tile data in VRAM.
void VDP_fillTileMap | ( | u16 | plan, |
u16 | tile, | ||
u16 | ind, | ||
u16 | num | ||
) |
Fill tilemap data.
plan | Plan where we want to fill tilemap data. Accepted values are:
|
tile | tile attributes data (see TILE_ATTR_FULL() and TILE_ATTR() macros). |
ind | tile index where to start fill. |
num | Number of tile to fill. |
void VDP_fillTileMapInc | ( | u16 | plan, |
u16 | basetile, | ||
u16 | ind, | ||
u16 | num | ||
) |
Fill tilemap data with index auto increment.
plan | Plan where we want to fill tilemap region. Accepted values are:
|
basetile | Base tile attributes data (see TILE_ATTR_FULL() and TILE_ATTR() macros). |
ind | tile index where to start fill. |
num | Number of tile to fill. |
Set the specified tilemap with specified tile attributes values.
The function auto increments tile index in tile attribute :
tilemap at index : basetile, basetile+1, basetile+2, basetile+3, ...
...
So this function is pratical to display image.
void VDP_fillTileMapRect | ( | u16 | plan, |
u16 | tile, | ||
u16 | x, | ||
u16 | y, | ||
u16 | w, | ||
u16 | h | ||
) |
Fill tilemap data at specified region.
plan | Plan where we want to fill tilemap region. Accepted values are:
|
tile | tile attributes data (see TILE_ATTR_FULL() and TILE_ATTR() macros). |
x | Region X start position (in tile). |
y | Region Y start position (in tile). |
w | Region Width (in tile). |
h | Region Heigh (in tile). |
Fill the specified tilemap region with specified tile attributes values.
void VDP_fillTileMapRectByIndex | ( | u16 | plan, |
u16 | tile, | ||
u16 | ind, | ||
u16 | num | ||
) |
void VDP_fillTileMapRectInc | ( | u16 | plan, |
u16 | basetile, | ||
u16 | x, | ||
u16 | y, | ||
u16 | w, | ||
u16 | h | ||
) |
Fill tilemap data with index auto increment at specified region.
plan | Plan where we want to fill tilemap region. Accepted values are:
|
basetile | Base tile attributes data (see TILE_ATTR_FULL() and TILE_ATTR() macros). |
x | Region X start position (in tile). |
y | Region Y start position (in tile). |
w | Region Width (in tile). |
h | Region Heigh (in tile). |
Set the specified tilemap region with specified tile attributes values.
The function auto increments tile index in tile attribute :
tilemap line 0 : basetile, basetile+1, basetile+2, basetile+3, ...
tilemap line 1 : basetile+w, basetile+w+1, basetile+w+2, ...
...
So this function is pratical to display image.
void VDP_fillTileMapRectIncByIndex | ( | u16 | plan, |
u16 | basetile, | ||
u16 | ind, | ||
u16 | num | ||
) |
void VDP_loadBMPTileData | ( | const u32 * | data, |
u16 | index, | ||
u16 | w, | ||
u16 | h, | ||
u16 | bmp_w | ||
) |
Load 4bpp bitmap tile data in VRAM.
data | Pointer to 4bpp bitmap tile data. |
index | Tile index where start tile data load (use TILE_USERINDEX as base user index). |
w | Width of bitmap region to load (in tile). |
h | Heigh of bitmap region to load (in tile). |
bmp_w | Width of bitmap (in tile), it can differ from 'w' parameter. |
This function does "on the fly" 4bpp bitmap conversion to tile data and transfert them to VRAM.
It's very helpful when you use bitmap images but the conversion eats sometime so you should use it only for static screen only.
For "in-game" condition you should use VDP_loadTileData() method with converted tile data.
See also VDP_loadBMPTileDataEx().
void VDP_loadBMPTileDataEx | ( | const u32 * | data, |
u16 | index, | ||
u16 | x, | ||
u16 | y, | ||
u16 | w, | ||
u16 | h, | ||
u16 | bmp_w | ||
) |
Load 4bpp bitmap tile data in VRAM.
data | Pointer to 4bpp bitmap tile data. |
index | Tile index where start tile data load (use TILE_USERINDEX as base user index). |
x | X start position of bitmap region to load (in tile). |
y | Y start position of bitmap region to load (in tile). |
w | Width of bitmap region to load (in tile). |
h | Heigh of bitmap region to load (in tile). |
bmp_w | Width of bitmap (in tile), it can differ from 'w' parameter. |
This function does "on the fly" 4bpp bitmap conversion to tile data and transfert them to VRAM.
It's very helpful when you use bitmap images but the conversion eats sometime so you should use it only for static screen only.
For "in-game" condition you should use VDP_loadTileData() method with converted tile data. See also VDP_loadBMPTileData()
u16 VDP_loadFont | ( | const TileSet * | font, |
u8 | use_dma | ||
) |
Load font from the specified TileSet structure.
font | TileSet containing the font. The TileSet is unpacked "on-the-fly" if needed (require some memory) |
use_dma | Use DMA transfert (faster but can lock Z80 execution). |
This fonction permits to replace system font by user font.
The font tile data are loaded to TILE_FONTINDEX and can contains FONT_LEN characters at max.
Each character should fit in one tile (8x8 pixels bloc).
See also VDP_loadFontData(..)
void VDP_loadFontData | ( | const u32 * | font, |
u16 | length, | ||
u8 | use_dma | ||
) |
Load font tile data in VRAM.
Note that you should prefer the VDP_loadBMPFont(..) method to this one (easier to use).
font | Pointer to font tile data. |
length | Number of characters of the font (max = FONT_LEN). |
use_dma | Use DMA transfert (faster but can lock Z80 execution). |
This fonction permits to replace system font by user font.
The font tile data are loaded to TILE_FONTINDEX and can contains FONT_LEN characters at max.
Each character should fit in one tile (8x8 pixels bloc).
See also VDP_loadFont(..) and VDP_loadTileData(..)
void VDP_loadTileData | ( | const u32 * | data, |
u16 | index, | ||
u16 | num, | ||
u8 | use_dma | ||
) |
Load tile data (pattern) in VRAM.
data | Pointer to tile data. |
index | Tile index where start tile data load (use TILE_USERINDEX as base user index). |
num | Number of tile to load. |
use_dma | Use DMA transfert (faster but can lock Z80 execution). |
Transfert rate:
~90 bytes per scanline in software (during blanking)
~190 bytes per scanline in hardware (during blanking)
u16 VDP_loadTileSet | ( | const TileSet * | tileset, |
u16 | index, | ||
u8 | use_dma | ||
) |
Load tile data (pattern) in VRAM.
tileset | Pointer to TileSet structure. The TileSet is unpacked "on-the-fly" if needed (require some memory) |
index | Tile index where start tile data load (use TILE_USERINDEX as base user index). |
use_dma | Use DMA transfert (faster but can lock Z80 execution). |
Transfert rate:
~90 bytes per scanline in software (during blanking)
~190 bytes per scanline in hardware (during blanking)
u16 VDP_setMap | ( | u16 | plan, |
const Map * | map, | ||
u16 | basetile, | ||
u16 | x, | ||
u16 | y | ||
) |
Load Map at specified position.
plan | Plan where we want to load Map. Accepted values are:
|
map | Map to load. |
basetile | Base index and flags for tile attributes (see TILE_ATTR_FULL() macro). |
x | Region X start position (in tile). |
y | Region Y start position (in tile). |
Load the specified Map at specified plan position.
u16 VDP_setMapEx | ( | u16 | plan, |
const Map * | map, | ||
u16 | basetile, | ||
u16 | x, | ||
u16 | y, | ||
u16 | xm, | ||
u16 | ym, | ||
u16 | wm, | ||
u16 | hm | ||
) |
Load Map region at specified position.
plan | Plan where we want to load Map. Accepted values are:
|
map | Map to load. |
basetile | Base index and flags for tile attributes (see TILE_ATTR_FULL() macro). |
x | Plan X destination position (in tile). |
y | Plan Y destination position (in tile). |
xm | Map region X start position (in tile). |
ym | Map region Y start position (in tile). |
wm | Map region Width (in tile). |
hm | Map region Heigh (in tile). |
Load the specified Map region at specified plan position.
void VDP_setTileMap | ( | u16 | plan, |
u16 | tile, | ||
u16 | ind | ||
) |
Set tilemap data at single position.
plan | Plan where we want to set tilemap data. Accepted values are:
|
tile | tile attributes data (see TILE_ATTR_FULL() and TILE_ATTR() macros). |
ind | position in tilemap. |
void VDP_setTileMapData | ( | u16 | plan, |
const u16 * | data, | ||
u16 | ind, | ||
u16 | num, | ||
u8 | use_dma | ||
) |
Load tilemap data at specified index.
plan | Plan where we want to load tilemap data. Accepted values are:
|
data | Tile attributes data pointer (see TILE_ATTR_FULL() and TILE_ATTR() macros). |
ind | Tile index where to start to set tilemap. |
num | Number of tile to set. |
use_dma | Use DMA transfert (faster but can lock Z80 execution). |
Set the specified tilemap with specified tile attributes values.
Transfert rate:
~90 bytes per scanline in software (during blanking)
~190 bytes per scanline in hardware (during blanking)
void VDP_setTileMapDataEx | ( | u16 | plan, |
const u16 * | data, | ||
u16 | basetile, | ||
u16 | ind, | ||
u16 | num | ||
) |
Load tilemap data at specified index (extended version).
plan | Plan where we want to load tilemap data. Accepted values are:
|
data | tile attributes data pointer (see TILE_ATTR_FULL() and TILE_ATTR() macros). |
basetile | Base tile index and flags for tile attributes (see TILE_ATTR_FULL() macro). |
ind | Tile index where to start to set tilemap. |
num | Number of tile to set. |
Set the specified tilemap with specified tile attributes values.
void VDP_setTileMapDataRect | ( | u16 | plan, |
const u16 * | data, | ||
u16 | x, | ||
u16 | y, | ||
u16 | w, | ||
u16 | h | ||
) |
Load tilemap data at specified region.
plan | Plan where we want to load tilemap data. Accepted values are:
|
data | tile attributes data pointer (see TILE_ATTR_FULL() and TILE_ATTR() macros). |
x | Region X start position (in tile). |
y | Region Y start position (in tile). |
w | Region Width (in tile). |
h | Region Heigh (in tile). |
Set the specified tilemap region with specified tile attributes values.
void VDP_setTileMapDataRectEx | ( | u16 | plan, |
const u16 * | data, | ||
u16 | basetile, | ||
u16 | x, | ||
u16 | y, | ||
u16 | w, | ||
u16 | h, | ||
u16 | wm | ||
) |
Load tilemap data at specified region (extended version).
plan | Plan where we want to load tilemap data. Accepted values are:
|
data | tile attributes data pointer (see TILE_ATTR_FULL() macro). |
basetile | Base index and flags for tile attributes (see TILE_ATTR_FULL() macro). |
x | Region X start position (in tile). |
y | Region Y start position (in tile). |
w | Region Width (in tile). |
h | Region Heigh (in tile). |
wm | Source tilemap data width (in tile). |
Set the specified tilemap region with specified tile attributes values.
void VDP_setTileMapRectByIndex | ( | u16 | plan, |
const u16 * | data, | ||
u16 | ind, | ||
u16 | num, | ||
u8 | use_dma | ||
) |
void VDP_setTileMapRectEx | ( | u16 | plan, |
const u16 * | data, | ||
u16 | baseindex, | ||
u16 | baseflags, | ||
u16 | x, | ||
u16 | y, | ||
u16 | w, | ||
u16 | h | ||
) |
void VDP_setTileMapXY | ( | u16 | plan, |
u16 | tile, | ||
u16 | x, | ||
u16 | y | ||
) |
Set tilemap data at single position.
plan | Plan where we want to set tilemap data. Accepted values are:
|
tile | tile attributes data (see TILE_ATTR_FULL() and TILE_ATTR() macros). |
x | X position (in tile). |
y | y position (in tile). |